<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <el-container>
        <el-header style="background-color: #0095d7">
            <h1 style="color: white;font-size: 22px">
                星光书店后台管理系统
                <span
                      style="float: right;font-size: 15px">欢迎xxx回来
                    <a href="">退出登录</a>
                </span>
            </h1>
        </el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu style="height: 500px"
                         @select="handleSelect"
                         default-active="2"
                         class="el-menu-vertical-demo">
                    <el-submenu index="1">
                        <template slot="title">
                            <i class="el-icon-s-flag"></i>
                            <span>分类管理</span>
                        </template>
                        <el-menu-item index="1-1">图书分类列表</el-menu-item>
                        <el-menu-item index="1-2">添加图书分类</el-menu-item>
                    </el-submenu>
                    <el-submenu index="2">
                        <template slot="title">
                            <i class="el-icon-picture"></i>
                            <span>轮播图管理</span>
                        </template>
                        <el-menu-item index="2-1">轮播图列表</el-menu-item>
                        <el-menu-item index="2-2">添加轮播图</el-menu-item>
                    </el-submenu>
                    <el-submenu index="3">
                        <template slot="title">
                            <i class="el-icon-shopping-cart-2"></i>
                            <span>销量榜单管理</span>
                        </template>
                        <el-menu-item index="3-1">本周热卖榜单</el-menu-item>
                        <el-menu-item index="3-2">本月热卖榜单</el-menu-item>
                    </el-submenu>
                    <el-submenu index="4">
                        <template slot="title">
                            <i class="el-icon-collection"></i>
                            <span>图书管理</span>
                        </template>
                        <el-menu-item index="4-1">图书列表</el-menu-item>
                        <el-menu-item index="4-2">添加图书</el-menu-item>
                    </el-submenu>
                    <el-submenu index="5">
                        <template slot="title">
                            <i class="el-icon-s-goods"></i>
                            <span>订单管理</span>
                        </template>
                        <el-menu-item index="5-1">订单列表</el-menu-item>
                    </el-submenu>
                    <el-submenu index="6">
                        <template slot="title">
                            <i class="el-icon-edit-outline"></i>
                            <span>公告管理</span>
                        </template>
                        <el-menu-item index="6-1">公告信息</el-menu-item>
                        <el-menu-item index="6-2">添加公告</el-menu-item>
                    </el-submenu>


                </el-menu>

            </el-aside>
            <el-main>
                <el-table v-if="currentIndex=='1-1'"
                          :data="categoryArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号" ></el-table-column>
                    <el-table-column
                            prop="name"
                            label="分类名称"
                            width="180">
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button size="mini" @click=""
                                       type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除此分类吗?"
                                    @confirm=""
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>

                        </template>
                    </el-table-column>
                </el-table>
                <el-table v-if="currentIndex=='2-1'"
                          :data="bannerArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column
                            label="轮播图"
                            width="180">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click=""
                                        type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除此轮播图吗?"
                                    @confirm=""
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>

                <el-table v-if="currentIndex=='3-1'"
                          :data="cateArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="category" label="图书分类" width="150"></el-table-column>
                    <el-table-column prop="title" label="图书标题" width="150"></el-table-column>
                    <el-table-column prop="price" label="价格" width="80"></el-table-column>
                    <el-table-column prop="oldPrice" label="原价" width="80"></el-table-column>
                    <el-table-column prop="saleCount" label="销量" width="80"></el-table-column>
                    <el-table-column
                            label="图书图片"
                            width="100">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click=""
                                        type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除该图书销量吗?"
                                    @confirm=""
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>
                <el-table v-if="currentIndex=='3-2'"
                          :data="cate1Arr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="category" label="图书分类" width="150"></el-table-column>
                    <el-table-column prop="title" label="图书标题" width="150"></el-table-column>
                    <el-table-column prop="price" label="价格" width="80"></el-table-column>
                    <el-table-column prop="oldPrice" label="原价" width="80"></el-table-column>
                    <el-table-column prop="saleCount" label="销量" width="80"></el-table-column>
                    <el-table-column
                            label="图书图片"
                            width="100">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click=""
                                        type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除该图书销量吗?"
                                    @confirm=""
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>

                <el-table v-if="currentIndex=='4-1'"
                          :data="productArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="category" label="图书分类" width="150"></el-table-column>
                    <el-table-column prop="title" label="商品标题" width="200"></el-table-column>
                    <el-table-column prop="price" label="价格" width="80"></el-table-column>
                    <el-table-column prop="oldPrice" label="原价" width="80"></el-table-column>
                    <el-table-column prop="saleCount" label="销量" width="80"></el-table-column>
                    <el-table-column
                            label="商品图片"
                            width="100">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click=""
                                        type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除此图书吗?"
                                    @confirm=""
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>

                <el-table v-if="currentIndex=='5-1'"
                          :data="Arr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="title" label="商品标题" width="200"></el-table-column>
                    <el-table-column prop="price" label="价格" width="80"></el-table-column>
                    <el-table-column prop="oldPrice" label="原价" width="80"></el-table-column>
                    <el-table-column prop="num" label="数量" width="80"></el-table-column>
                    <el-table-column
                            label="商品图片"
                            width="100">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click="productUpdate(scope.row)"
                                        type="success">处理</el-button>
                            <el-popconfirm
                                    title="您确定删除此商品吗?"
                                    @confirm="productDelete(scope.$index, scope.row)"
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>

                <el-table v-if="currentIndex=='6-1'"
                          :data="noticeArr"
                          style="width: 100%">

                    <!--type=index 设置这一列显示的内容为编号-->
<!--                    <el-form >-->
<!--                        <el-form-item label="公告标题" label-width="80px">-->
<!--                            <el-input type="text" v-model="p.price"></el-input>-->
<!--                        </el-form-item>-->
<!--                        <el-form-item label="公告标题" label-width="300px">-->
<!--                            <el-input type="text" v-model="p.price"></el-input>-->
<!--                        </el-form-item>-->
<!--                    </el-form>-->

                    <el-table-item label="操作">
                        <!--scope里面装着当前行所对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应的对象
                        -->
                        <template slot-scope="scope">
                            <el-button  size="mini" @click="productUpdate(scope.row)"
                                        type="success">修改</el-button>
                            <el-popconfirm
                                    title="您确定删除此商品吗?"
                                    @confirm="productDelete(scope.$index, scope.row)"
                            >
                                <el-button slot="reference"  size="mini"
                                           type="danger">删除</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-item>
                </el-table>

            </el-main>
        </el-container>
    </el-container>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                noticeArr:[],
                Arr:[{category:"梦幻类",title:"梦幻",price:500,oldPrice:30,saleCount:50,url:"imgs/103.jpg"}],
                currentIndex:"1-1",
                categoryArr:[{name:"神话"},{name:"童话"}],
                bannerArr:[{url:"./imgs/101.jpg"},{url:"./imgs/102.jpg"}],
                cate1Arr:[{category:"梦幻类",title:"梦幻",price:500,oldPrice:30,saleCount:50,url:"imgs/103.jpg"}],
                cateArr:[{category:"类",title:"梦幻西游",price:500,oldPrice:30,saleCount:50,url:"imgs/101.jpg"}],
                productArr:[{category:"梦幻类",title:"梦幻",price:500,oldPrice:30,saleCount:50,url:"imgs/103.jpg"}],
                user:{}
            }
        },
        methods:{

            handleSelect(key,keyPath){
                if (key=='1-2'){
                    let name = prompt("请输入分类的名称");
                    //点击取消
                    if (name==null){
                        return;
                    }
                    if (name==''){
                        v.$message.error("分类名称不能为空");
                        return;
                    }
                    //发出添加分类的请求
                    axios.get("/category/insert?name="+name).then(function (response) {
                        //添加分类后把所有的分类请求回来赋值给数组
                        v.categoryArr = response.data;
                    })
                }else if (key=='2-2'){
                    //跳转到添加轮播图页面
                    location.href="/insertBanner.html";
                }else if (key=='4-2'){
                    location.href="/insertBook.html";
                }else if(key=='6-2'){

                } else{
                    v.currentIndex = key;
                }
            }
        },
    })
</script>
</html>